/*
 * =====================================================================================
 *
 *       Filename:  test.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  09/13/12 15:09:42
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andyli (gl), andy.y.li@163.com
 *        Company:  gl
 *
 * =====================================================================================
 */

#include "dir.h"
#include <stdlib.h>

int main(int argc,char *argv[])
{
	string path = ".";
	string fmt = ".*";
	bool recursion = true;
	if (argc > 1){
		path = argv[1];
	}

	if (argc > 2){
		fmt = argv[2];
	}
	if (argc > 3){
		int re = atoi(argv[3]);
		recursion = (re?true:false);
	}

	Dir dir;
	dir.GetFiles(path,fmt,recursion);
	//dir.GetFiles();
	dir.show();

	string newDir = "tmp";
	if (!dir.IsExist(newDir)){
		dir.show();
		cout << "Not found the dir: " << newDir << 
			", and creating it..." << endl;
		if (dir.mkdir(newDir)){
			cout << "Finish.\n";
		}
	}
	else{
		cout << "Exist \'" << newDir << "\' and finish\n";
	}

	cout << "FileNAme: " << dir.fileName("//temp.txt") << endl;;
	cout << "sFileNAme: " << dir.fileName("//temp.txt/") << endl;;
	return 0;
}


